/* xminou.cc : The X-Minou Projet
 * X-Minou is a text, irc like chat program for
 * local users of Unix system
 *
 * Athors : David GUGLIELMI <david.guglielmi@gmail.com>
 *
 * X-Minou is a free software distribued as-is.
 */


#include <csignal>
#include <cstdlib>
#include <cstring>
#include <iostream>

#include <pwd.h>

#include "xminou.hh"
#include "xminou_intf.hh"

void exit_signal (int sig);

static NCursesIntf::NCursesIntf *app;

int
main (int argc, char *argv[])
{

  if (argc > 1)
   {
    if (strcmp (argv[1], "--version") == 0)
      std::cout << APP_NAME << " " << APP_VERSION << std::endl;
    else
      std::cout << "Usage : xminou++" << std::endl;
   }
  else
   {
    for (int i = SIGHUP; i < SIGSYS; i++)
     {
      if (i != SIGWINCH)
        std::signal (i, exit_signal);
     }

    app = new NCursesIntf::NCursesIntf ();

    app->run ();

    delete app;
   }

  (void) argc;

  return EXIT_SUCCESS;

}

char*
whoami (void)
{

  struct passwd *pw;
  
  pw = getpwuid (geteuid ());

  return pw->pw_name;

}

void
exit_signal (int sig)
{

  delete app;

  exit (EXIT_SUCCESS);

  (void)sig;  

}

